# -*- coding: utf-8 -*-
# filename: media.py
from basic import Basic
import json
import urllib2
import poster.encode
from poster.streaminghttp import register_openers

class Arti_Intel(object):
    def __init__(self):
        register_openers()
    #提交语音
    def upvoice(self, accessToken, formatType, voice_id, lang = 'zh_CN'):
        postUrl = "http://api.weixin.qq.com/cgi-bin/media/voice/addvoicetorecofortext?access_token=%s&format=%s&voice_id=%s&lang=%s" % (accessToken,formatType,voice_id,lang)
        urlResp = urllib2.urlopen(postUrl)
        print urlResp.read()    

    def getwords(self, accessToken, formatType, voice_id, lang = 'zh_CN'):
        postUrl = "http://api.weixin.qq.com/cgi-bin/media/voice/queryrecoresultfortext?access_token=%s&format=%s&voice_id=%s&lang=%s" % (accessToken,formatType,voice_id,lang)
        urlResp = urllib2.urlopen(postUrl)

    def gettrans(self,accessToken, from_content,lang = 'en_US')
        postUrl = "http://api.weixin.qq.com/cgi-bin/media/voice/translatecontent?access_token=%s&lfrom=%s&lto=%s" % (accessToken, from_content,lang)
        urlResp = urllib2.urlopen(postUrl)
        


if __name__ == '__main__':
    myMedia = Media()
    accessToken = Basic().get_access_token()

    #新建临时素材
    filePath = "/home/ben/Documents/weixin_service/image/image.jpg"   #请安实际填写
    mediaType = "image"
    myMedia.uplaod(accessToken, filePath, mediaType)
   
    #获取临时素材
    mediaId = "6559152202368476495"
    myMedia.get(accessToken, mediaId)